]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
browser-plugin: Use g_strndup to get a string property
authorJasper St. Pierre <jstpierre@mecheye.net>
Fri, 11 Nov 2011 04:57:39 +0000 (23:57 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Sat, 12 Nov 2011 18:38:36 +0000 (13:38 -0500)
WebKit-based browsers like Chromium and Epiphany may insert extra junk at the
end of NPStrings, so we cannot depend on the strlen matching.

https://bugzilla.gnome.org/show_bug.cgi?id=663823

browser-plugin/browser-plugin.c

index 2daa0ddcd749da7359dc1073151698a5393f7928..b71788939f541702f1343e5cade648f2c1c9f970 100644 (file)
@@ -71,10 +71,7 @@ get_string_property (NPP         instance,
     goto out;
 
   result_str = NPVARIANT_TO_STRING (result);
-  if (strlen (result_str.UTF8Characters) != result_str.UTF8Length)
-    goto out;
-
-  result_copy = g_strdup (result_str.UTF8Characters);
+  result_copy = g_strndup (result_str.UTF8Characters, result_str.UTF8Length);
 
  out:
   funcs.releasevariantvalue (&result);